#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int arr[500000],tmp[500000];

void find_reverse_pair(int begin, int end, int* ans)
{
	if (begin >= end)
		return;
	int mid = (begin + end) / 2;
	find_reverse_pair(begin, mid, ans);
	find_reverse_pair(mid + 1, end, ans);
	int i = begin;
	int j = mid + 1;
	int t = begin;
	while (i <= mid && j <= end)
	{
		if (arr[i] > arr[j])
		{
			(*ans)+=mid - i + 1;
			tmp[t++] = arr[j++];
		}
		else
			tmp[t++] = arr[i++];
	}
	while (i <= mid)
		tmp[t++] = arr[i++];
	while (j <= end)
		tmp[t++] = arr[j++];
	for (int s = begin; s <= end; s++)
		arr[s] = tmp[s];
}

int main()
{
	int n = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &arr[i]);
	long ans = 0;
	find_reverse_pair(0,n-1,&ans);
	printf("%d", ans);
	return 0;
}